//
//  MovieDetailView.m
//  doubanMovie
//
//  Created by lanou3g on 15/11/20.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "MovieDetailView.h"
#import "MovieDetail.h"

@interface MovieDetailView ()





@end

@implementation MovieDetailView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self allViews];
    }
    return self;
}

- (void)setMovieDetail:(MovieDetail *)movieDetail
{
    if (movieDetail.poster != nil) {
        NSURL *rul = [[NSURL alloc] initWithString:movieDetail.poster];
        NSData *data = [NSData dataWithContentsOfURL:rul];
        self.pictureImage = [UIImage imageWithData:data];
        self.pictureView = [[UIImageView alloc] initWithImage:self.pictureImage];
        self.pictureView.frame = CGRectMake(10, 20, 110, 150);
        [self addSubview:self.pictureView];
    }

    self.ratingLabel.text = [NSString stringWithFormat:@"评分: %@",movieDetail.rating];
    self.rating_countLabel.text = [NSString stringWithFormat:@"(%@评论)",movieDetail.rating_count];
    self.runtimeLabel.text = movieDetail.runtime;
    self.release_dateLabel.text = movieDetail.release_date;
    self.genresLabel.text = movieDetail.genres;
    self.countryLabel.text = movieDetail.country;
    self.actorsLabel.text = movieDetail.actors;
    self.plot_simpleLabel.text = movieDetail.plot_simple;
    
}

- (void)allViews
{
    self.movieDetail = [[MovieDetail alloc] init];
    

    
    self.ratingLabel = [[UILabel alloc] initWithFrame:CGRectMake(150, 20, 80, 22)];
    [self addSubview:self.ratingLabel];
    
    self.rating_countLabel = [[UILabel alloc] initWithFrame:CGRectMake(240, 20, 90, 22)];
    [self addSubview:self.rating_countLabel];
    
    self.release_dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(150, 52, 200, 22)];
//    self.release_dateLabel.backgroundColor = [UIColor redColor];
    [self addSubview:self.release_dateLabel];
    
    self.runtimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(150, 84, 200, 22)];
//    self.runtimeLabel.backgroundColor = [UIColor redColor];
    [self addSubview:self.runtimeLabel];
    
    self.genresLabel = [[UILabel alloc] initWithFrame:CGRectMake(150, 116, 200, 22)];
//    self.genresLabel.backgroundColor = [UIColor redColor];
    [self addSubview:self.genresLabel];
    
    self.countryLabel = [[UILabel alloc] initWithFrame:CGRectMake(150, 148, 200, 22)];
//    self.countryLabel.backgroundColor = [UIColor redColor];
    [self addSubview:self.countryLabel];

    self.actorLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 190, 150, 40)];
//    self.actorLabel.backgroundColor = [UIColor redColor];
    self.actorLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:20];
    self.actorLabel.text = @"制作人";
    
    [self addSubview:self.actorLabel];
    
    self.actorsLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(self.actorLabel.frame) + 20, 350, 100)];
    self.actorsLabel.numberOfLines = 0;
//    self.actorsLabel.backgroundColor = [UIColor redColor];
    [self addSubview:self.actorsLabel];
    
    self.moviePlot_simpleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(self.actorsLabel.frame) + 20, 150 , 40)];
    self.moviePlot_simpleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:20];
    self.moviePlot_simpleLabel.text = @"电影情节";
//    self.moviePlot_simpleLabel.backgroundColor = [UIColor redColor];
    [self addSubview:self.moviePlot_simpleLabel];
    
    self.plot_simpleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(self.moviePlot_simpleLabel.frame) + 20, 350, 100)];
    self.plot_simpleLabel.numberOfLines = 0;
//    self.plot_simpleLabel.backgroundColor = [UIColor redColor];
    
    [self addSubview:self.plot_simpleLabel];
    
}




@end
